<?php
include 'partials/header.php';
require __DIR__ . '/notes/notes.php';

if (!isset($_GET['id'])) {
    include "partials/not_found.php";
    exit;
}
$noteId = $_GET['id'];

$note = getnoteById($noteId);
if (!$note) {
    include "partials/not_found.php";
    exit;
}

$errors = [
    'name' => "",
    'value' => ""
];

if ($_SERVER['REQUEST_METHOD'] === 'POST') {
    $note = array_merge($note, $_POST);
    updatenote($note, $noteId);
    header("Location: index.php");
}

?>

<?php include '_form.php' ?>
<?php include 'partials/footer.php' ?>